<?php
/**
* @package   auto_occasion
* @subpackage localite
* @author    your name
* @copyright 2011 your name
* @link      http://www.yourwebsite.undefined
* @license    All rights reserved
*/

class FoLocaliteCtrl extends jController {
    /**
    *Fonction pour afficher la liste des types d'entreprises par département, région et ville
    */
    function index() {

         jClasses::inc('commun~common');

         $rep = $this->getResponse('htmlFo');
         $idType      = $this->intParam('id', 0);
          //xml pour le header : title, desc, keywords
         $path = '';
         switch ($idType) {
             case 1:
                 $path = PATH_XML_LOCALITE_CASSE ;
                 break;
             case 2:
                 $path = PATH_XML_LOCALITE_SANS_PERMIS ;
                 break;
             case 4:
                 $path = PATH_XML_LOCALITE_LOCATION ;
                 break;
             case 5:
                 $path = PATH_XML_LOCALITE_CONTROLE ;
                 break;

             default:
                 break;
         }
         
        $headerContent = common::readXml($path);
        // change le header de la page en cours
		$rep->title						= isset($headerContent->title)?$headerContent->title:'';
		$headerContent->title			= isset($headerContent->title)?$headerContent->title:'' ;
		$headerContent->keywords		= isset($headerContent->keywords)? $headerContent->keywords:'' ;
		$headerContent->desc			= isset($headerContent->desc)? $headerContent->desc:'' ;
		$keywords						= "<meta name='keywords' content='" . $headerContent->keywords . "'>" ;
		$description					= "<meta name='Description' content='" . $headerContent->desc. "'>" ;
        $rep->addHeadContent($keywords);
        $rep->addHeadContent($description);
        // ---
         $rep->menusActifs = frontHtmlResponse::MENU_ESSAI;        
         $rep->breadCrumb  = array(frontHtmlResponse::MENU_ACCUEIL, frontHtmlResponse::MENU_LOCALITE) ;


         jClasses::inc('commun~common');
         jClasses::inc('localite~localiteSrv');

         
         $type        = common::chargeParId($idType, 'ao_type_entreprise');
         $dept        = localiteSrv::getDepartement($idType);
         $region      = localiteSrv::getRegion($idType);
         $ville       = localiteSrv::getVille($idType);

         $rep->bodyTpl = 'localite~FoLocalite';
         $rep->body->assign("type", $type);
         $rep->body->assign("dept", $dept);
         $rep->body->assign("region", $region);
         $rep->body->assign("ville", $ville); 
        //pubHidden et rightContent
        $paramPub = array('p1'=>PUB_RIGHT_1_ID,'p2'=>PUB_RIGHT_2_ID,'p3'=>PUB_RIGHT_3_ID,'p4'=>PUB_RIGHT_4_ID,'p5'=>PUB_RIGHT_5_ID,'p6'=>PUB_RIGHT_6_ID);
        $rep->body->assignZone('oZonePubHidden', 'commun~FoPubHidden',$paramPub);
        
        $paramRight = array('ad'=>1, 'no_need_cc2'=>1);
        $rep->body->assignZone('oZoneRightContent', 'commun~FoRightContent',$paramRight);

         return $rep;


    }

    function marque() {
        jClasses::inc('commun~common');

         $rep = $this->getResponse('htmlFo');
          //xml pour le header : title, desc, keywords
        $headerContent = common::readXml(PATH_XML_LOCALITE_MARQUE);
        // change le header de la page en cours
        $rep->title						= isset($headerContent->title)?$headerContent->title:'';
		$headerContent->title			= isset($headerContent->title)?$headerContent->title:'' ;
		$headerContent->keywords		= isset($headerContent->keywords)? $headerContent->keywords:'' ;
		$headerContent->desc			= isset($headerContent->desc)? $headerContent->desc:'' ;
		$keywords						= "<meta name='keywords' content='" . $headerContent->keywords . "'>" ;
		$description					= "<meta name='Description' content='" . $headerContent->desc. "'>" ;
        $rep->addHeadContent($keywords);
        $rep->addHeadContent($description);
        // ---
         $rep->menusActifs = frontHtmlResponse::MENU_ESSAI;        
         $rep->breadCrumb  = array(frontHtmlResponse::MENU_ACCUEIL, frontHtmlResponse::MENU_LOCALITE_MARQUE) ;

         jClasses::inc('marqueModele~marqueSrv');

         $marque       = marqueSrv::getAll();

         $rep->bodyTpl = 'localite~FoLocaliteMarque';
         $rep->body->assign("marque", $marque);
         $rep->body->assignZone('oZoneLocaliteRight', 'localite~FoLocaliteRight');

         return $rep;

    }

    function departement() {
        jClasses::inc('commun~common');

         $rep = $this->getResponse('htmlFo');
           //xml pour le header : title, desc, keywords
        $headerContent = common::readXml(PATH_XML_LOCALITE_DEPARTEMENT);
        // change le header de la page en cours
        $rep->title						= isset($headerContent->title)?$headerContent->title:'';
		$headerContent->title			= isset($headerContent->title)?$headerContent->title:'' ;
		$headerContent->keywords		= isset($headerContent->keywords)? $headerContent->keywords:'' ;
		$headerContent->desc			= isset($headerContent->desc)? $headerContent->desc:'' ;
		$keywords						= "<meta name='keywords' content='" . $headerContent->keywords . "'>" ;
		$description					= "<meta name='Description' content='" . $headerContent->desc. "'>" ;
        $rep->addHeadContent($keywords);
        $rep->addHeadContent($description);
        // ---
         $rep->menusActifs = frontHtmlResponse::MENU_ESSAI;        
         $rep->breadCrumb  = array(frontHtmlResponse::MENU_ACCUEIL, frontHtmlResponse::MENU_LOCALITE_DEPARTEMENT) ;

         jClasses::inc('localite~localiteSrv');
         $marque          = $this->intParam('marque',0);
         $region          = localiteSrv::listeRegion();
         $departement     = localiteSrv::listeDepartement();
         $ville           = localiteSrv::listeVille();
         $ville           = localiteSrv::listeVilleBis($ville);
         $temp = array();
         if (sizeof ($ville)) {
             foreach ($ville as $k=>$item) {
                 if (preg_match('/[aA-zZ]/', $item)) {
                    $temp[] = $item;
                 }
             }
             $ville = $temp;
         }
         $rep->bodyTpl    = 'localite~FoLocaliteDepartement';
         $rep->body->assign("region", $region);
         $rep->body->assign("departement", $departement);
         $rep->body->assign("ville", $ville);
         $rep->body->assign("marque", $marque);

         //pubHidden et rightContent
        $paramPub = array('p1'=>PUB_RIGHT_1_ID,'p2'=>PUB_RIGHT_2_ID,'p3'=>PUB_RIGHT_3_ID,'p4'=>PUB_RIGHT_4_ID,'p5'=>PUB_RIGHT_5_ID,'p6'=>PUB_RIGHT_6_ID);
        $rep->body->assignZone('oZonePubHidden', 'commun~FoPubHidden',$paramPub);
        
        $paramRight = array('ad'=>1,'no_need_cc2'=>1);
        $rep->body->assignZone('oZoneRightContent', 'commun~FoRightContent', $paramRight);
        //---

         return $rep;

    }

    /**
    *Fonction pour afficher la liste des marques pour la recherche d'annonces par marque et localité( département, région et ville)
    */

    function marquedept() {

         jClasses::inc('commun~common');

         $rep = $this->getResponse('htmlFo');
           //xml pour le header : title, desc, keywords
        $headerContent = common::readXml(PATH_XML_LOCALITE_MARQUE_DEPARTEMENT);
        // change le header de la page en cours
        $rep->title						= isset($headerContent->title)?$headerContent->title:'';
		$headerContent->title			= isset($headerContent->title)?$headerContent->title:'' ;
		$headerContent->keywords		= isset($headerContent->keywords)? $headerContent->keywords:'' ;
		$headerContent->desc			= isset($headerContent->desc)? $headerContent->desc:'' ;
		$keywords						= "<meta name='keywords' content='" . $headerContent->keywords . "'>" ;
		$description					= "<meta name='Description' content='" . $headerContent->desc. "'>" ;
	
        $rep->addHeadContent($keywords);
        $rep->addHeadContent($description);
        // ---
         $rep->menusActifs = frontHtmlResponse::MENU_ESSAI;        
         $rep->breadCrumb  = array(frontHtmlResponse::MENU_ACCUEIL, frontHtmlResponse::MENU_LOCALITE_MARQUE) ;

         jClasses::inc('marqueModele~marqueSrv');

         $marque       = marqueSrv::getAll();

         $rep->bodyTpl = 'localite~FoLocaliteMarqueDept';
         $rep->body->assign("marque", $marque);
         $rep->body->assignZone('oZoneLocaliteRight', 'localite~FoLocaliteRight');

         return $rep;

    }

}

